package com.ikdong.toodle.model;

import java.util.Date;

import android.util.Log;

import com.ikdong.toodle.util.Constant;

public class Authentication {
	public String email;
	public String pass;
	public String key;
	public String userId;
	public long dateTime;
	
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPass() {
		return pass;
	}
	public void setPass(String pass) {
		this.pass = pass;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public long getDateTime() {
		return dateTime;
	}
	public void setDateTime(long dateTime) {
		this.dateTime = dateTime;
	}
	
	public static String[] getColumns(){
		return new String[]{"email","pass","userid","key","date_time"};
	}
	
	public boolean isValid(){
		boolean flag = false;
		try{
			long now = new Date().getTime();
			if((now-this.getDateTime())<(4*3600*1000)){
				flag = true;
			}
		}catch(Exception e){
			Log.e(Constant.TAG, "Authentication.isKeyValid() error", e);
		}
		return flag;
	}
}
